home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 003 / dbaseacc.arc / FINDBILL.PRG < prev    next >
Encoding:
Text File  |  1979-12-31  |  5.1 KB  |  164 lines

  1.           **********FINDBILLS COMMAND FILE **********
  2. * This procedure finds specific bills that we are looking for, then allows
  3. * us to edit them.
  4. *      The bill can be specified by bill number and/or amount.  If you decide
  5. * not to pay a bill that was found specifying more than one item, you will be
  6. * presented the rest of the entries for the supplier based on names only.
  7. ***************************************************************************
  8.  
  9. SELECT PRIMARY
  10. USE CostBase INDEX $Supp
  11.  
  12. STORE 'N' TO Finished
  13. DO WHILE !(Finished) <> 'F'
  14.  
  15.    * "Entering" controls a closed loop that allows the operator to change
  16.    * the entry if he or she spots and error.
  17.    STORE "C" TO Entering
  18.    DO WHILE !(Entering) = 'C'
  19.       ERASE
  20.       @ 4,0
  21.       ACCEPT ' NAME OF SUPPLIER ' TO MName
  22.       ACCEPT '   INVOICE NUMBER ' TO MBILL:Nmbr
  23.       ACCEPT '     ENTER AMOUNT ' TO Temp
  24.       STORE !(MNAME) To MName
  25.       STORE !(MBill:Nmbr) TO MBill:Nmbr
  26.       STORE VAL(Temp) TO MAmount
  27.       STORE MAmount*1.00 TO MAmount
  28.       @  6,19 SAY MName
  29.       @  7,19 SAY MBill:Nmbr
  30.       @  8,19 SAY MAmount
  31.       @ 11, 0 SAY '        C to CHANGE,'
  32.       ? '     <Return> to continue.'
  33.  
  34.       * OneByOne is used so that we look at the entire listing for a name once.
  35.       * If we could have started in the middle of the list and the bill is not
  36.       * the one we want, we go up to the first listing then go through all the
  37.       * entries for the name, one by one.  Used in the last loop in this file.
  38.       IF Bill:Nmbr > '     ' .OR. Amount <> 0
  39.          STORE 0 TO OneByOne
  40.       ELSE
  41.          STORE 1 TO OneByOne
  42.       ENDIF
  43.  
  44.       WAIT TO Entering
  45.    ENDDO Entering
  46.  
  47.    STORE T TO Looking
  48.    @ 11, 0 SAY "I'M LOOKING, I'M LOOKING!!"
  49.    @ 12,0
  50.    @ 13,0
  51.  
  52.    * Now look for a match on the first 10 characters of the names.  This finds
  53.    * the first entry for that supplier, then looks for bill number or amount
  54.    * if we specified them.  If not specified, it skips through all the entries
  55.    * for the name.
  56.  
  57.    IF LEN (MName) > 10
  58.       STORE $(MName,1,10) TO Key
  59.    ELSE
  60.       STORE MName TO Key
  61.    ENDIF
  62.  
  63.    FIND &Key
  64.  
  65.    @ 11, 0
  66.    IF # = 0
  67.       ?
  68.       ? "   GEE, I CAN'T FIND THE NAME.  Please check the spelling."
  69.       ? "   Or maybe it hasn't been posted to the COSTBASE YET."
  70.       ? '<Return> to continue.'
  71.       WAIT
  72.       ERASE
  73.    ELSE
  74.       * Found at least one entry with a matching name.
  75.       STORE T TO Looking
  76.       IF MBill:Nmbr = ' ' .AND. MAmount = 0
  77.          STORE F TO Looking
  78.       ELSE
  79.          * If we have more than the name, we first check for the bill number.
  80.          IF MBill:Nmbr > ' '
  81.             DO WHILE Name=Key .AND. .NOT. EOF .AND. Looking
  82.                 IF Bill:Nmbr <> MBill:Nmbr
  83.               SKIP
  84.            ELSE
  85.               STORE F TO Looking
  86.            ENDIF
  87.             ENDDO
  88.  
  89.         * If we're on a new name of the end of the file, Looking is TRUE
  90.             * because we have not found the supplier we were looking for.
  91.         * Otherwise, we have a matching bill number to confirm.
  92.         IF Looking
  93.            ? '   This BILL NUMBER is not in the costbase.'
  94.            ? '<Return> to continue.'
  95.              WAIT
  96.             ENDIF
  97.          ELSE
  98.  
  99.         * If no bill number, look for the amount.
  100.         DO WHILE Name=Key .AND. .NOT. EOF .AND. Looking
  101.            IF Amount <> MAmount
  102.               Skip
  103.                ELSE
  104.           STORE F TO Looking
  105.            ENDIF
  106.             ENDDO
  107.  
  108.             * If we're on a new name or the end of the file, Looking is TRUE
  109.             * Otherwise, we have an unpaid bill to confirm.
  110.         IF Looking
  111.            ? '   No bill for this amount and this supplier.'
  112.            ? '<Return> to continue.'
  113.            WAIT
  114.             ENDIF  
  115.          ENDIF we have the bill number
  116.       ENDIF we have only the name
  117.    ENDIF there is an unpaid bill for the supplier
  118.  
  119.    STORE 'N' TO Changing
  120.    DO WHILE !(Changing) <> 'Y' .AND. .NOT. Looking
  121.       @ 12,0
  122.       DISPLAY
  123.       ? CHR(7)
  124.       ? '        E to EDIT this record,'
  125.       ? '        Q to QUIT this supplier,'
  126.       ACCEPT '     <Return> to continue.' TO Changing
  127.       ?
  128.  
  129.   IF !(Changin) = 'Q'
  130.      STORE T TO Looking
  131.   ELSE
  132.      IF !(Changing) = 'E'
  133.     STORE STR(#,5) TO Found
  134.     EDIT &Number
  135.     ERASE
  136.      ELSE
  137.     * If the first record is not the one we want, we skip through the
  138.     * rest of the entries for the name.  We first go on from where we
  139.      * were in the listing (if we had more than the name), then go back
  140.     * to the first entry and look at those we had skipped.  If we had
  141.     * only the name, OneByOne = 1 and we go through the list only once.
  142.     SKIP
  143.     IF EOF .OR. Name <> Key
  144.        IF OneByOne = 0
  145.           FIND &Key
  146.           STORE 1 TO OneByOne
  147.        ELSE
  148.           @ 11, 0 SAY CHR(27) + CHR(74)
  149.           ? "We've gone through all the entries for " + MName+'.'
  150.           ? '<Return> to continue.'
  151.           STORE T TO Looking
  152.           WAIT
  153.            ENDIF
  154.        ENDIF we've gone through the list
  155.      ENDIF is it the right record
  156.   ENDIF
  157. ENDDO Changing the record
  158. ?
  159. ?  '       F if FINISHED finding bills,'
  160. ?  '    <Return> to continue.'
  161. ?  CHR(7)
  162. WAIT TO Finished
  163. ENDDO Finished 
  164.